package ph.com.gs3.formalistics.presenter.fragments.views;

import ph.com.gs3.formalistics.R;
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class DeveloperOptionsViewFragment extends Fragment {

	Context context;

	public static final String TAG = DeveloperOptionsViewFragment.class.getSimpleName();

	private Button bResetDatabase;
	private Button bTestCommModule;
	private Button bTestNotifications;

	private DeveloperOptionsViewActionListener listener;

	public DeveloperOptionsViewFragment() {};

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);

		try {
			listener = (DeveloperOptionsViewActionListener) activity;
		} catch (ClassCastException e) {
			throw new IllegalStateException(activity.getClass().getSimpleName()
			        + " does not implement DeveloperOptionsViewActionListener");
		}
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_developer_options, container, false);

		context = getActivity();

		bResetDatabase = (Button) rootView.findViewById(R.id.DevOpt_bResetDatabase);
		bResetDatabase.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View view) {
				listener.onResetDatabaseCommand();
			}
		});

		bTestCommModule = (Button) rootView.findViewById(R.id.DevOpt_bTestCommModule);
		bTestCommModule.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				listener.onTestCommModuleCommand();
			}
		});

		bTestNotifications = (Button) rootView.findViewById(R.id.DevOpt_bTestNotifications);
		bTestNotifications.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				listener.onTestNotificationsCommand();
			}
		});

		return rootView;
	}

	public static interface DeveloperOptionsViewActionListener {
		public void onResetDatabaseCommand();

		public void onTestCommModuleCommand();

		public void onTestNotificationsCommand();
	}

}
